import {ajax, defaultBefore,silentAfter} from "@/utils/ajax.js"

export const fetchNotices = ({id,pageNo=1,pageSize=10}) =>{
	return ajax({
		url:'/userGroupNotice/byGrpupIdList',
		data:{
			id,
			pageNo,
			pageSize
		}
	})
}

export const fetchNoticeDetail = (id)=>{
	return ajax({
		url:'/userGroupNotice/detail',
		data:{
			id
		}
	})
}

export const addNotice = ({
	gid,
	title,
	content,
	type=2,
	href,
	hrefType
})=>{
	return ajax({
		url:'/userGroupNotice/add',
		data:{
			groupId:gid,
			noticeTitle:title,
			noticeContent:content,
			noticeType:type,
			href,
			hrefType
		}
	})
}

export const modifyNotice = ({
	id,
	gid,
	title,
	content,
	type=2,
	href,
	hrefType
})=>{
	return ajax({
		url:'/userGroupNotice/update',
		data:{
			id,
			groupId:gid,
			noticeTitle:title,
			noticeContent:content,
			noticeType:type,
			href,
			hrefType
		}
	})
}

export const removeNotice = (id)=>{
	return ajax({
		url:'/userGroupNotice/delete',
		data:{
			id
		}
	})
}

export const joinGroup = ({id,inviteUserId})=>{
	return ajax({
		url:'/userGroup/joinGroup',
		data:{
			id,
			inviteUserId
		}
	})
}

export const isInGroup = (id) =>{
	return ajax({
		url:'/userGroup/isInGroup',
		data:{
			id
		}
	})
}

export const fetchFriendsInGroup = (id) =>{
	return ajax({
		url:'/userGroup/isHaveMyFriend',
		data:{
			id
		}
	})
}

export const applyJoin = ({inviteUserId,groupId})=>{
	return ajax({
		url:'/userGroupApply/cardInviteAdd',
		data:{
			inviteUserId,
			groupId
		}
	})
}

export const inviteFriendJoin = ({userId,groupId})=>{
	return ajax({
		url:'/userGroupApply/inviteAdd',
		data:{
			userId,
			groupId
		}
	})
}

export const fetchApplyCount = ({groupId,status})=>{
	return ajax({
		url:'/userGroupApply/joinUserApplyCount',
		data:{
			groupId,
			status
		},
		defaultBefore,
		silentAfter
	})
}


export const setSaveTime = ({id,time})=>{
	return ajax({
		url:'/userGroup/upMsgSveTime',
		data:{
			id,
			time
		}
	})
}
export const timeList = [
	{label:'永久',value:-1},
	{label:'1小时',value:60*60},
	{label:'1天',value:60*60*24},
	{label:'1周',value:60*60*24*7},
	{label:'1月',value:60*60*24*30},
	{label:'90天',value:60*60*24*90},
	{label:'180天',value:60*60*24*180},
	{label:'1年',value:60*60*24*365}
]

export const setShowRead = ({id,state})=>{
	return ajax({
		url:'/userGroup/upShowRead',
		data:{
			id,
			state
		}
	})
}


export const setShowRedMine = ({id,state})=>{
	return ajax({
		url:'/userGroup/upShowRedMine  ',
		data:{
			id,
			state
		}
	})
}


export const setSendRedPacket   = ({id,state})=>{
	return ajax({
		url:'/userGroup/upSendRedPacket',
		data:{
			id,
			state
		}
	})
}


export const setSendCard = ({id,state})=>{
	return ajax({
		url:'/userGroup/upSendCard',
		data:{
			id,
			state
		}
	})
}


export const setSendFile = ({id,state})=>{
	return ajax({
		url:'/userGroup/upSendFile',
		data:{
			id,
			state
		}
	})
}

export const setRecallMsg = ({id,state})=>{
	return ajax({
		url:'/userGroup/upRecallMsg',
		data:{
			id,
			state
		}
	})
}

export const getMemberRole = ({id,uid})=>{
	return ajax({
		url:'/userGroupRel/userGroupAuth',
		data:{
			groupId:id,
			userId:uid
		}
	})
}
